<template>
  <div>
    <el-upload
      ref="elUpload"
      :multiple="false"
      :show-file-list="false"
      :http-request="uploadFileMethod"
      :before-upload="beforeUpload"
      :disabled="isDisabled"
      accept=".xls,.xlsx"
      action
      class="file-uploader"
    >
      <span style="font-size:14px;display:block;text-align:center;">{{ btnText }}</span>
      <!-- <div v-if="isMedium" :style="mediumBtnStyle" class="medium-import-btn">
        {{ btnText }}
      </div> -->
    </el-upload>
  </div>
</template>
<script>
import ImportList from '@/mixins/importList';
import ImportIcon from '@/assets/medium/import.png';

export default {
  name: 'ImportButton',
  mixins: [ImportList],
  props: {
    // 按钮文字
    btnText: {
      type: String,
      default: '导入excel'
    },
    // 按钮样式
    mediumBtnStyle: {
      type: Object,
      default: () => {
        return {};
      }
    },
    // 控制是否显示成功和失败提示框
    hideConfirm: {
      type: Boolean,
      default: false
    },
    // 是否可以点击
    isDisabled: {
      type: Boolean,
      default: false
    },
    isMedium: {
      type: Boolean,
      default: false
    },
    importApi: {
      type: String,
      default: () => {
        return '';
      }
    },
    getList: { // 导入后列表刷新的方法
      type: Function,
      default: null
    }
  },
  data() {
    return {
      ImportIcon,
      isSealing: false,
      limitNum: false,
      uploadId: ''
    };
  },
  methods: {
    setUploadId(uploadId) {
      this.uploadId = uploadId;
    }
  }
};
</script>
<style rel="stylesheet/scss" lang="scss">
.file-uploader {
  ::v-deep {
    .el-upload {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
